﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    public record ModifyRoleCommand(long Id, string Name, string Description) : IRequest<ModifyRoleResult>;

    public class ModifyRoleCommandHandler : IRequestHandler<ModifyRoleCommand, ModifyRoleResult>
    {
        private readonly IRoleService _roleService;
        public ModifyRoleCommandHandler(IRoleService roleService)
            => _roleService = roleService;

        public async Task<ModifyRoleResult> Handle(ModifyRoleCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.ModifyRoleAsync(request.Id, request.Name, request.Description);
        }
    }
}
